<?php

class Portal_model extends CI_Model {

	function Portal_model() {
		// Call the Model constructor
		parent::__construct();
	}

	//Get Featured Banner - Home page
	//Feature
	function getHomeFeaturedImage($lang) {
		if($lang == "english") {
			$lang = 1;
		}
		$tsql_callSP = '{call sp_getHomeFeaturedImage(?)}';

		$params = array(
		array($lang, SQLSRV_PARAM_IN)
		);

		$results = $this->db->exec_query($tsql_callSP, $params);

		$data = array();

		if($results) {
			while ($row = sqlsrv_fetch_array($results, SQLSRV_FETCH_ASSOC)) {
				$data[] = $row;
			}
		}

		return $data;
	}
	
	function getVideo($page = 'Home', $market = 'ID') {
		/*
		$str = "select TOP 1 p.Page_ID, p.SystemName,pb.PageFID,b.Link
				from dbo.Pages p
				left join dbo.PageBanner pb ON p.Page_ID = pb.PageFID
				left join dbo.Banner b ON b.BannerGroupFID = pb.BannerFID
				WHERE p.SystemName = '". $this->db->escape_str($page) ."' and p.MarketFID = '". $this->db->escape_str($market) ."'";
		*/
		$str = "select p.Page_ID, p.SystemName,pb.BannerFID,pb.PageFID,b.Link
				from dbo.Pages p
				left join dbo.PageBanner pb ON p.Page_ID = pb.PageFID
				left join dbo.Banner b ON pb.BannerFID = b.Banner_ID
				WHERE p.SystemName = '". $this->db->escape_str($page) ."' and p.MarketFID = '". $this->db->escape_str($market) ."' and b.LanguageFID =". $this->config->item('config_language_id') ."";
		
		$query = $this->db->query($str);
		
		return $query->row();
	}

}

?>
